package com.example.d6_tcp3;

import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * 服务端
 */
public class Server {
    public static void main(String[] args) throws IOException {
        System.out.println("服务端启动...");
        ServerSocket serverSocket = new ServerSocket(8888);
        while (true) {
            Socket socket = serverSocket.accept();

            System.out.println(socket.getRemoteSocketAddress() + "上线了");

            /**
             * 把客户端对应的socket通信管道，交给一个独立的线程处理，提高效率
             */
            new ServerReaderThread(socket).start();
        }


    }
}
